#include "evdeploy/runtime/sophon/sophon_base.h"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"

#define EV_ID_MAXLEN (1024)

namespace ev
{

    EVSophonModel::EVSophonModel() { EVLOG(INFO) << "this is a sophon engine"; }

    EVSophonModel::~EVSophonModel() {}

    void EVSophonModel::LoadBmModel(const std::string str_model_name)
    {
        EVLOG(INFO) << "load bm model";
        int ret = m_sophon_model_handle.loadModel(str_model_name, m_ctx_ptr, m_handle_ptr, m_dev_id);
        if (ret != 0)
        {
            EVLOG(ERROR) << "load bm model wrong, please check";
            exit(-1);
        }
        m_ctx_ptr->get_network_names(&m_net_names);
        if (m_net_names.size() > 1)
        {
            EVLOG(WARNING) << "more than one network name";
        }
        m_net_ptr = std::make_shared<bmruntime::Network>(*m_ctx_ptr, m_net_names[0]);
        EVLOG(INFO) << "load bm model done";
        m_is_ok = true;
    }

} // namespace ev
